26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
51 #pragma package(smart_init)
64 Graphics::TBitmap* SmallGraphicPtrVal) : SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
66 for(
int x = 0; x < 4; x++)
77 else if(SpeedTagVal == 77)
81 else if(SpeedTagVal == 78)
85 else if(SpeedTagVal == 79)
89 else if(SpeedTagVal == 96)
93 else if(SpeedTagVal == 129)
97 else if(SpeedTagVal == 130)
101 else if(SpeedTagVal == 131)
105 else if(SpeedTagVal == 145)
109 else if(SpeedTagVal == 146)
118 FixedNamedLocationElement(false)
120 for(
int x = 0; x < 4; x++)
131 AnsiString(VLocInput));
144 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
158 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
174 Graphics::TBitmap *GraphicOutput = GraphicPtr;
176 if(LocationName ==
"")
221 GraphicOutput = GraphicPtr;
225 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
227 if((TrackType ==
Simple) && Failed)
239 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
240 AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit01) +
"," + AnsiString(TrainIDOnBridgeOrFailedPointOrigSpeedLimit23) +
",EndTrkEl,";
249 Attribute(0), CallingOnSet(false), Length01(
Utilities->DefaultTrackLength), Length23(-1), SpeedLimit01(
Utilities->DefaultTrackSpeedLimit), SpeedLimit23(-1),
250 TrainIDOnElement(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit01(-1), TrainIDOnBridgeOrFailedPointOrigSpeedLimit23(-1), StationEntryStopLinkPos1(-1), StationEntryStopLinkPos2(-1),
251 SigAspect(FourAspect)
254 for(
int x = 0; x < 4; x++)
270 if(lower.second < higher.second)
274 else if(lower.second > higher.second)
278 else if(lower.second == higher.second)
280 if(lower.first < higher.first)
293 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
294 CheckCount(9), IsARoute(false), AutoSignals(false), PrefDirRoute(false)
298 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
309 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
337 {2, 4}, {6, 2}, {8, 6}, {4, 8},
338 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
348 else if(
Link[2] == -1)
361 else if(
Link[2] == -1)
370 for(
int x = 0; x < 16; x++)
372 if(((Entry == EXArray[x][0]) && (Exit == EXArray[x][1])) || ((Entry == EXArray[x][1]) && (Exit == EXArray[x][0])))
548 throw Exception(
"Error in EntryExitNumber 4");
643 throw Exception(
"Error in EntryExitNumber 5");
737 throw Exception(
"Error in EntryExitNumber 6");
824 throw Exception(
"Error in EntryExitNumber 10");
913 throw Exception(
"Error in EntryExitNumber 11");
1009 throw Exception(
"Error in EntryExitNumber 7");
1040 throw Exception(
"Error in EntryExitNumber 8");
1051 if((ELink > 0) && (ELink < 10) && (ELink != 5))
1053 if(!AutoSigsFlag && !PrefDirRoute)
1057 else if(!AutoSigsFlag && PrefDirRoute)
1068 throw Exception(
"Error in EntryExitNumber 9");
1165 AnsiString NL =
'\n';
1167 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable, perhaps because of failed points; " + NL + NL +
1168 "reachable but with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
1169 "blocked by a train, another route or a changing level crossing; " + NL + NL +
1170 "or invalid - possibly due to a preferred direction mismatch, or a missed signal in a blue route or green route restricted to consecutive signals.";
1177 int InternalLinkCheckArray[9][2] =
1178 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
1183 for(
int x = 0; x < 9; x++)
1185 for(
int y = 0; y < 2; y++)
1192 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
1194 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
1195 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
1196 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
1197 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27
1198 << 60 << 61 << 62 << 63 << 68 << 69 << 70 << 71 << 80 << 81 << 82 << 83 << 125 << 126 << 127 << 128;
1204 int HVArray[10][2] =
1205 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
1207 for(
int x = 0; x < 10; x++)
1209 for(
int y = 0; y < 2; y++)
1218 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1221 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1222 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1224 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
1225 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
1227 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1228 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1231 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1234 for(
int x = 0; x < 40; x++)
1240 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1243 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
1244 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
1246 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1247 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1249 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1250 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1253 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1256 for(
int x = 0; x < 40; x++)
1262 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
1265 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
1266 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1268 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1269 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1271 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1272 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1275 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1278 for(
int x = 0; x < 40; x++)
1304 for(
int x = 0; x < 40; x++)
1310 {{68, 0,
RailGraphics->
FSig68}, {69, 0,
RailGraphics->
FSig69}, {70, 0,
RailGraphics->
FSig70}, {71, 0,
RailGraphics->
FSig71}, {72, 0,
RailGraphics->
FSig72},
1313 for(
int x = 0; x < 8; x++)
1319 {{68, 0,
RailGraphics->
FGSig68}, {69, 0,
RailGraphics->
FGSig69}, {70, 0,
RailGraphics->
FGSig70}, {71, 0,
RailGraphics->
FGSig71}, {72, 0,
RailGraphics->
FGSig72},
1322 for(
int x = 0; x < 8; x++)
1349 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1350 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1351 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1352 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1353 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1354 {0, 0, 129}, {0, -1, 145},
1357 for(
int x = 0; x < 25; x++)
1359 for(
int y = 0; y < 3; y++)
1367 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1368 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1369 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1370 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1371 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1372 {0, 0, 129}, {0, 1, 145},
1375 for(
int x = 0; x < 25; x++)
1377 for(
int y = 0; y < 3; y++)
1385 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1386 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1387 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1388 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1389 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1390 {0, 0, 130}, {-1, 0, 146},
1393 for(
int x = 0; x < 25; x++)
1395 for(
int y = 0; y < 3; y++)
1403 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1404 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1405 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1406 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1407 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1408 {0, 0, 130}, {1, 0, 146},
1411 for(
int x = 0; x < 25; x++)
1413 for(
int y = 0; y < 3; y++)
1421 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1422 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1423 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1424 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1425 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1426 {0, -1, 129}, {1, 0, 130},
1427 {-1, 0, 130}, {0, 1, 145},
1428 {0, -1, 145}, {1, 0, 146},
1431 for(
int x = 0; x < 28; x++)
1433 for(
int y = 0; y < 3; y++)
1451 for(
int x = 0; x < 8; x++)
1453 for(
int y = 0; y < 3; y++)
1471 for(
int x = 0; x < 8; x++)
1473 for(
int y = 0; y < 3; y++)
1491 for(
int x = 0; x < 8; x++)
1493 for(
int y = 0; y < 3; y++)
1511 for(
int x = 0; x < 8; x++)
1513 for(
int y = 0; y < 3; y++)
1521 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1523 for(
int x = 0; x < 4; x++)
1525 for(
int y = 0; y < 3; y++)
1533 0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1534 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1535 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1536 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1542 0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1543 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1544 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1545 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1551 0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1552 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1553 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1554 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1560 0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1561 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1562 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1563 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1585 delete UGMIt->second;
1661 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1662 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1664 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1671 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1672 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1685 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1686 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1688 {4, 6, 2, 8}, {1, 9, 3, 7},
1690 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1692 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8}, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1695 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1696 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6}, {3, 7, 4, 6},
1697 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1698 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1},
1699 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1700 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1701 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1},
1703 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1704 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1705 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1706 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1707 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1708 {4, 6, -1, -1}, {2, 8, -1, -1},
1710 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1712 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1714 {4, 6, -1, -1}, {2, 8, -1, -1},
1719 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1720 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1721 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1722 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1725 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1726 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1727 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1729 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1730 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1731 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1733 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1735 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1736 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1737 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1738 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1739 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1740 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1741 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1742 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1743 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1744 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1745 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1746 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1747 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1749 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1750 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1751 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1752 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1753 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1754 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1755 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1756 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1760 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1761 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1762 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1768 for(
int x = 0; x < 17; x++)
1770 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1772 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1776 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1782 ExistingGraphicLoaded(false), Width(16), Height(16)
1794 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1832 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1836 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1840 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1844 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1867 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1870 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1874 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1878 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1912 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1933 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1947 bool TrackPresent =
false;
1961 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1965 TrackPresent =
true;
1970 return(!TrackPresent);
1978 bool TrackPresent =
false;
1987 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1991 TrackPresent =
true;
1997 return(!TrackPresent);
2002 void TTrack::EraseTrackElement(
int Caller,
int HLocInput,
int VLocInput,
int &ErasedTrackVectorPosition,
bool &TrackEraseSuccessfulFlag,
bool InternalChecks)
2005 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2006 TrackEraseSuccessfulFlag =
false;
2011 ErasedTrackVectorPosition = -1;
2012 AnsiString SName =
"", ErrorString;
2014 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
2020 TrackMapKeyPair.first = HLocInput;
2021 TrackMapKeyPair.second = VLocInput;
2022 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
2033 if(ErrorString !=
"")
2035 throw Exception(ErrorString +
" for EraseTrackElement 1");
2059 ErasedTrackVectorPosition = VecPos;
2060 TrackEraseSuccessfulFlag =
true;
2066 unsigned int VecPos;
2067 InactiveTrackMapKeyPair.first = HLocInput;
2068 InactiveTrackMapKeyPair.second = VLocInput;
2073 VecPos = InactiveTrack2MultiMapIterator->second;
2078 if(ErrorString !=
"")
2080 throw Exception(ErrorString +
" for EraseTrackElement 2A");
2090 TrackEraseSuccessfulFlag =
true;
2111 VecPos = InactiveTrack2MultiMapIterator->second;
2116 if(ErrorString !=
"")
2118 throw Exception(ErrorString +
" for EraseTrackElement 2B");
2142 if(TrackEraseSuccessfulFlag)
2164 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2165 bool PlatAllowedFlag =
false;
2167 TrackLinkingRequiredFlag =
false;
2179 LocationNameEntry.first =
"";
2187 TempTrackElement.
HLoc = HLocInput;
2188 TempTrackElement.
VLoc = VLocInput;
2214 else if(Aspect == 1)
2218 else if(Aspect == 2)
2222 else if(Aspect == 3)
2231 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2234 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2236 if(InactiveFoundFlag)
2240 NonStationOrLevelCrossingPresent =
true;
2244 NonStationOrLevelCrossingPresent =
true;
2248 PlatformPresent =
true;
2259 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2267 PlatAllowedFlag =
true;
2271 PlatAllowedFlag =
true;
2275 PlatAllowedFlag =
true;
2279 PlatAllowedFlag =
true;
2283 TrackLinkingRequiredFlag =
true;
2311 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1048, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2312 (!FoundFlag && !InactiveFoundFlag))
2315 TrackLinkingRequiredFlag =
true;
2347 TrackLinkingRequiredFlag =
true;
2359 else if(FoundFlag || InactiveFoundFlag)
2378 bool BothPointFillets =
true;
2393 TrackLinkingRequiredFlag =
true;
2407 bool InternalChecks)
2411 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2412 bool PlatAllowedFlag =
false;
2414 TrackLinkingRequiredFlag =
false;
2417 LocationNameEntry.first =
"";
2423 TempTrackElement.
HLoc = HLocInput;
2424 TempTrackElement.
VLoc = VLocInput;
2425 for(
int x = 0; x < 4; x++)
2431 TempTrackElement.
Conn[x] = -1;
2435 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2446 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2448 if(InactiveFoundFlag)
2452 NonStationOrLevelCrossingPresent =
true;
2456 NonStationOrLevelCrossingPresent =
true;
2460 PlatformPresent =
true;
2471 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2479 PlatAllowedFlag =
true;
2483 PlatAllowedFlag =
true;
2487 PlatAllowedFlag =
true;
2491 PlatAllowedFlag =
true;
2495 TrackLinkingRequiredFlag =
true;
2526 if((FoundFlag && (
NameAllowed.Contains(
TrackElementAt(1055, VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2527 (!FoundFlag && !InactiveFoundFlag))
2530 TrackLinkingRequiredFlag =
true;
2565 TrackLinkingRequiredFlag =
true;
2577 else if(FoundFlag || InactiveFoundFlag)
2596 bool BothPointFillets =
true;
2611 TrackLinkingRequiredFlag =
true;
2641 ShowMessage(
"Gaps must be set before track can be validated");
2651 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2662 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2679 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2686 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2710 std::pair<AnsiString, char>TempMapPair;
2718 TempMapPair.second =
'x';
2728 AnsiString Name =
"";
2729 typedef std::list<AnsiString> TNoPlatsList;
2730 TNoPlatsList::iterator NPLIt;
2731 TNoPlatsList NoPlatsList;
2732 typedef std::list<AnsiString> TLocNameList;
2733 TLocNameList LocNameList;
2738 LocNameList.push_back(LNMMIt->first);
2741 LocNameList.unique();
2742 for(TLocNameList::iterator LNLIt = LocNameList.begin(); LNLIt != LocNameList.end(); LNLIt++)
2746 if(MMRange.first == MMRange.second)
2752 if((LNMMIt->second) < 0)
2766 TempIt = MMRange.second;
2767 if(LNMMIt == --TempIt)
2769 NoPlatsList.push_back(Name);
2773 if(!NoPlatsList.empty())
2775 AnsiString NoPlatsAnsiList =
"";
2776 for(NPLIt = NoPlatsList.begin(); NPLIt != NoPlatsList.end(); NPLIt++)
2778 NoPlatsAnsiList += *NPLIt +
'\n';
2782 if(NoPlatsList.size() > 1)
2784 ShowMessage(
"Please note: the following locations have no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2788 ShowMessage(
"Please note: the following location has no platforms, trains won't be able to stop or pass there:-\n\n" + NoPlatsAnsiList +
"\nThis message will not be shown again.");
2803 int NewHLoc, NewVLoc;
2804 bool ConnectionFoundFlag, LinkFoundFlag;
2806 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2808 for(
unsigned int y = 0; y < 4; y++)
2826 ConnectionFoundFlag =
false;
2827 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2833 ConnectionFoundFlag =
true;
2835 LinkFoundFlag =
false;
2836 for(
unsigned int a = 0; a < 4; a++)
2840 LinkFoundFlag =
true;
2856 if(!ConnectionFoundFlag)
2931 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2948 bool UnsetGaps =
false;
2955 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2959 for(
unsigned int y = 0; y < 4; y++)
2971 for(
unsigned int y = 0; y < 4; y++)
2981 for(
unsigned int y = 1; y < 4; y++)
2990 for(
unsigned int y = 0; y < 4; y++)
3003 for(
unsigned int y = 0; y < 4; y++)
3031 int NumberOfActiveElements = 0;
3033 GraphicsFollow =
false;
3037 if(MarkerString[MarkerString.Length()] ==
'1')
3039 GraphicsFollow =
true;
3041 for(
int x = 0; x < NumberOfActiveElements; x++)
3047 TrackElement.
HLoc = TempInt;
3049 TrackElement.
VLoc = TempInt;
3055 TrackElement.
Conn[0] = TempInt;
3079 if((TempInt != -1) && (TempInt < 10))
3089 if((TempInt != -1) && (TempInt < 10))
3106 if(Marker[1] ==
'3')
3110 else if(Marker[1] ==
'2')
3114 else if(Marker[1] ==
'G')
3128 int NumberOfInactiveElements = 0;
3132 for(
int x = 0; x < NumberOfInactiveElements; x++)
3138 TrackElement.
HLoc = TempInt;
3140 TrackElement.
VLoc = TempInt;
3146 bool LocError =
false;
3175 for(
int x = 0; x < NumberOfGraphics; x++)
3186 bool FileError =
false;
3188 for(
int x = 0; x < NumberOfGraphics; x++)
3201 UGME.second =
new TPicture;
3202 UGME.second->LoadFromFile(
UGME.first);
3205 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
3212 catch(
const EInvalidGraphic &e)
3221 delete UGMIt->second;
3226 catch(
const Exception &e)
3235 delete UGMIt->second;
3243 bool FoundInMap =
false;
3262 UGME.second =
new TPicture;
3263 UGME.second->LoadFromFile(
UGME.first);
3266 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
3273 catch(
const EInvalidGraphic &e)
3282 delete UGMIt->second;
3287 catch(
const Exception &e)
3296 delete UGMIt->second;
3321 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
3325 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
3327 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
3330 VecFile << x <<
'\n';
3331 VecFile << TrackElement.
SpeedTag <<
'\n';
3332 VecFile << TrackElement.
HLoc <<
'\n';
3333 VecFile << TrackElement.
VLoc <<
'\n';
3337 VecFile << TrackElement.
Conn[0] <<
'\n';
3341 VecFile << TrackElement.
Attribute <<
'\n';
3347 VecFile << int(1) <<
'\n';
3351 VecFile << int(0) <<
'\n';
3354 VecFile << TrackElement.
Length01 <<
'\n';
3355 VecFile << TrackElement.
Length23 <<
'\n';
3358 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3365 VecFile <<
"3*****" <<
'\0' <<
'\n';
3369 VecFile <<
"2*****" <<
'\0' <<
'\n';
3373 VecFile <<
"G*****" <<
'\0' <<
'\n';
3377 VecFile <<
"4*****" <<
'\0' <<
'\n';
3382 VecFile <<
"******" <<
'\0' <<
'\n';
3387 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
3391 VecFile << x <<
'\n';
3392 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
3393 VecFile << InactiveTrackElement.
HLoc <<
'\n';
3394 VecFile << InactiveTrackElement.
VLoc <<
'\n';
3395 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
3396 VecFile <<
"******" <<
'\0' <<
'\n';
3411 GraphicsFollow =
false;
3413 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
3419 AnsiString MarkerString;
3426 if(MarkerString[MarkerString.Length()] ==
'1')
3428 GraphicsFollow =
true;
3430 for(
int x = 0; x < NumberOfActiveElements; x++)
3438 int SpeedTag = TempInt;
3445 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3451 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3456 if((SpeedTag > 87) && (SpeedTag < 96))
3459 if((TempInt < -1) || (TempInt > 3))
3465 if((TempInt < -1) || (TempInt > 999999))
3471 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3472 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3475 if((TempInt < -1) || (TempInt > 5))
3481 if((SpeedTag >= 68) && (SpeedTag <= 75))
3484 if((TempInt != 0) && (TempInt != 1))
3491 if((TempInt < -1) || (TempInt > 999999))
3497 if((TempInt < -1) || (TempInt > 999999))
3503 if((TempInt < -1) || (TempInt > 999999))
3509 if((TempInt < -1) || (TempInt > 999999))
3530 int NumberOfInactiveElements = 0;
3533 if(NumberOfInactiveElements < 0)
3543 for(
int x = 0; x < NumberOfInactiveElements; x++)
3557 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3563 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3590 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3596 AnsiString FileName =
"", TempStr =
"";
3598 for(
int x = 0; x < NumberOfGraphics; x++)
3600 TPicture *TempPicture =
new TPicture;
3609 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3622 catch(
const EInvalidGraphic &e)
3627 for(
int y = x + 1; y < NumberOfGraphics; y++)
3633 ShowMessage(FileName +
3634 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3639 catch(
const Exception &e)
3644 for(
int y = x + 1; y < NumberOfGraphics; y++)
3650 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3651 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3669 for(
int x = 0; x < VecSize; x++)
3692 for(
int x = 0; x < VecSize; x++)
3714 for(
int x = 0; x < VecSize; x++)
3768 for(
int x = 0; x < VecSize; x++)
3826 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3848 if(BothPointFilletsAndBasicLCs)
3923 Bitmap->Canvas->CopyMode = cmSrcCopy;
3925 Graphics::TBitmap *GraphicOutput;
4100 for(
int x = 0; x < 40; x++)
4129 Graphics::TBitmap *GraphicPtr;
4144 Graphics::TBitmap* SignalPlatformGraphic;
4177 if(OldTransparentColour !=
clB5G5R5)
4200 Bitmap->Canvas->CopyMode = cmSrcCopy;
4228 Bitmap->Canvas->CopyMode = cmSrcCopy;
4230 Graphics::TBitmap *GraphicOutput;
4240 if(BaseElement == 1)
4336 for(
int x = 0; x < 40; x++)
4365 Graphics::TBitmap *GraphicPtr;
4380 Graphics::TBitmap* SignalPlatformGraphic;
4443 for(
int x = 0; x < 40; x++)
4451 Graphics::TBitmap* SignalPlatformGraphic;
4492 if(OldTransparentColour !=
clB5G5R5)
4506 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4578 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4592 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4618 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4643 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4673 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4707 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4744 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4761 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4778 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4808 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4815 throw Exception(
"Error - Map & Vector different sizes");
4817 unsigned int NonZeroCount = 0;
4819 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4828 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4834 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4838 TrackMapEntry.first = TrackMapKeyPair;
4839 TrackMapEntry.second = x;
4840 if(!(
TrackMap.insert(TrackMapEntry).second))
4842 throw Exception(
"Error - map insertion failure, TrackVector in error");
4846 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4848 for(
unsigned int y = 0; y < 4; y++)
4873 THVPair GapMapKeyPair, GapMapValuePair;
4876 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4882 GapMapEntry.first = GapMapKeyPair;
4885 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
4889 GapMapEntry.second = GapMapValuePair;
4892 GapMap.insert(GapMapEntry);
4907 bool TrackElementPositionsOK =
true;
4909 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4921 "Footbridge or underpass connection error. Each end must connect to a platform, concourse "
4922 "or other footbridge or underpass, and they can't connect to each other (i.e. a footbridge "
4923 "can't connect to an underpass or vice versa)");
4931 for(
unsigned int y = 0; y < 4; y++)
4949 bool ConnectionFoundFlag;
4953 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
4959 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4968 if(ConnectionFoundFlag)
4973 bool ExitSignal =
false;
4984 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
4986 TrackElementPositionsOK =
false;
4991 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
4993 TrackElementPositionsOK =
false;
4998 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
5002 TrackElementPositionsOK =
false;
5007 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
5010 TrackElementPositionsOK =
false;
5022 ShowMessage(
"Bridge next to a signal - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
5025 TrackElementPositionsOK =
false;
5030 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
5031 TrackElementPositionsOK =
false;
5034 if(!TrackElementPositionsOK)
5041 throw Exception(
"Error in track element positions in FinalCall");
5054 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5060 for(
unsigned int y = 0; y < 4; y++)
5082 bool ConnectionFoundFlag;
5083 bool LinkMatchFound =
false;
5086 if(ConnectionFoundFlag)
5088 for(
unsigned int a = 0; a < 4; a++)
5097 LinkMatchFound =
true;
5108 throw Exception(
"Error in final track linkage - - no matching link found");
5121 throw Exception(
"Error in final track linkage - connection not found");
5136 bool ConnErrorFlag =
false;
5138 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5142 ConnErrorFlag =
true;
5146 ConnErrorFlag =
true;
5150 ConnErrorFlag =
true;
5154 ConnErrorFlag =
true;
5162 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5171 throw Exception(
"ConnError in LinkTrack - Final");
5175 throw Exception(
"ConnError in LinkTrack - Precheck");
5178 bool CLkErrorFlag =
false;
5180 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5184 CLkErrorFlag =
true;
5188 CLkErrorFlag =
true;
5192 CLkErrorFlag =
true;
5196 CLkErrorFlag =
true;
5204 throw Exception(
"CLkError in LinkTrack - Final");
5208 throw Exception(
"CLkError in LinkTrack - Precheck");
5213 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5243 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5259 for(
unsigned int y = 0; y < 4; y++)
5278 bool ConnectionFoundFlag;
5284 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
5293 if(ConnectionFoundFlag)
5296 bool LinkFoundFlag =
false;
5353 for(
unsigned int a = 0; a < 4; a++)
5362 LinkFoundFlag =
true;
5370 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
5380 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
5393 bool ConnErrorFlag =
false;
5395 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5399 ConnErrorFlag =
true;
5403 ConnErrorFlag =
true;
5407 ConnErrorFlag =
true;
5411 ConnErrorFlag =
true;
5419 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
5428 throw Exception(
"ConnError in LinkTrack - Final");
5432 throw Exception(
"ConnError in LinkTrack - Precheck");
5435 bool CLkErrorFlag =
false;
5437 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5441 CLkErrorFlag =
true;
5445 CLkErrorFlag =
true;
5449 CLkErrorFlag =
true;
5453 CLkErrorFlag =
true;
5461 throw Exception(
"CLkError in LinkTrack - Final");
5465 throw Exception(
"CLkError in LinkTrack - Precheck");
5469 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5498 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5514 for(
unsigned int y = 0; y < 4; y++)
5533 bool ConnectionFoundFlag =
false;
5535 if(ConnectionFoundFlag)
5539 bool LinkFoundFlag =
false;
5559 for(
unsigned int a = 0; a < 4; a++)
5568 LinkFoundFlag =
true;
5588 bool ConnErrorFlag =
false;
5590 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5594 ConnErrorFlag =
true;
5598 ConnErrorFlag =
true;
5602 ConnErrorFlag =
true;
5606 ConnErrorFlag =
true;
5614 bool CLkErrorFlag =
false;
5616 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
5620 CLkErrorFlag =
true;
5624 CLkErrorFlag =
true;
5628 CLkErrorFlag =
true;
5632 CLkErrorFlag =
true;
5650 int Position1, Position2;
5656 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
5658 int HLoc1 = GapMapPtr->first.first;
5659 int VLoc1 = GapMapPtr->first.second;
5660 int HLoc2 = GapMapPtr->second.first;
5661 int VLoc2 = GapMapPtr->second.second;
5664 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
5668 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
5672 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
5676 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
5694 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
5695 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
5705 bool FoundFlag =
false;
5717 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5718 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5719 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5748 bool FoundFlag =
false;
5761 TrackMapKeyPair.first = TrackElement.
HLoc;
5762 TrackMapKeyPair.second = TrackElement.
VLoc;
5763 TrackMapEntry.first = TrackMapKeyPair;
5768 LocationNameEntry.second = -(int)(
TrackVector.size());
5808 TrackMapKeyPair.first = HLoc;
5809 TrackMapKeyPair.second = VLoc;
5810 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5820 return(TrackMapPtr->second);
5833 TrackMapKeyPair.first = HLoc;
5834 TrackMapKeyPair.second = VLoc;
5835 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5838 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5839 throw Exception(Message);
5857 MapKeyPair.first = HLoc;
5858 MapKeyPair.second = VLoc;
5859 MapPtr = Map.find(MapKeyPair);
5860 if(MapPtr == Map.end())
5862 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc) +
" in GetTrackElementFromAnyTrackMap";
5863 throw Exception(Message);
5868 return(Vector.at(MapPtr->second));
5878 THVPair InactiveTrackMapKeyPair;
5881 InactiveTrackMapKeyPair.first = HLoc;
5882 InactiveTrackMapKeyPair.second = VLoc;
5886 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5887 throw Exception(Message);
5901 bool Present =
true;
5905 TrackMapKeyPair.first = HLoc;
5906 TrackMapKeyPair.second = VLoc;
5907 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5922 bool Present =
true;
5923 THVPair InactiveTrackMapKeyPair;
5926 InactiveTrackMapKeyPair.first = HLoc;
5927 InactiveTrackMapKeyPair.second = VLoc;
5945 THVPair InactiveTrackMapKeyPair;
5950 InactiveTrackMapKeyPair.first = HLoc;
5951 InactiveTrackMapKeyPair.second = VLoc;
5960 if(InactiveTrackRange.first == InactiveTrackRange.second)
5969 RetPair.first = InactiveTrackRange.first->second;
5970 RetPair.second = (--InactiveTrackRange.second)->second;
5983 AnsiString(DivergingPosition));
5994 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
5995 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
5996 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
5997 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
5998 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
5999 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
6000 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
6001 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
6002 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
6003 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
6004 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
6005 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
6039 throw Exception(
"Error, Wrong track type in PlotGap");
6041 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
6045 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
6049 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
6053 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
6057 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
6061 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
6065 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
6069 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
6073 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
6077 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
6081 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
6085 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
6089 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
6093 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
6097 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
6101 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
6117 PosPair.first = TrackElement.
HLoc;
6118 PosPair.second = TrackElement.
VLoc;
6122 Disp->
PlotOutput(283, TrackElement.
HLoc * 16, TrackElement.
VLoc * 16, MOMIt->second);
6135 throw Exception(
"Error, Wrong track type in PlotPoints");
6146 else if(TrackElement.
SpeedTag < 132)
6157 else if(!TrackElement.
Failed)
6164 else if(TrackElement.
SpeedTag < 132)
6182 else if(TrackElement.
SpeedTag < 132)
6216 throw Exception(
"Error, Wrong track type in PlotSignal");
6220 for(
int x = 0; x < 40; x++)
6291 for(
int x = 0; x < 40; x++)
6298 Graphics::TBitmap* SignalPlatformGraphic;
6313 for(
int x = 0; x < 8; x++)
6328 for(
int x = 0; x < 8; x++)
6419 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
6427 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
6435 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
6443 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
6459 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
6467 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
6475 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
6483 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
6516 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
6528 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
6540 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
6552 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
6594 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
6596 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6598 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
6601 if(BaseElementSpeedTag == 1)
6605 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
6612 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
6620 Graphics::TBitmap *RouteGraphic;
6622 if(TypeOfRoute == 1)
6626 else if(TypeOfRoute == 0)
6632 RouteGraphic = BaseGraphic;
6639 if(UpStep == DownStep)
6642 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
6652 else if((DownStep - UpStep) == 1)
6657 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6667 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6680 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6690 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6706 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6716 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6726 else if(DownStep == 0)
6729 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6739 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
6752 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6762 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6772 for(
int x = (UpStep + 1); x < DownStep; x++)
6777 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
6781 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
6802 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
6809 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
6815 Graphics::TBitmap *RouteGraphic;
6817 if(TypeOfRoute == 1)
6821 else if(TypeOfRoute == 0)
6827 RouteGraphic = BaseGraphic;
6836 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
6846 else if((RStep - LStep) == 1)
6851 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6861 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6874 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6884 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6900 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6910 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6923 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6933 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6946 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6956 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6966 for(
int x = (LStep + 1); x < RStep; x++)
6971 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
6975 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
6999 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7002 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7004 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7006 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
7009 if(BaseElementSpeedTag == 1)
7013 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
7020 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
7026 if(UpStep == DownStep)
7037 else if((DownStep - UpStep) == 1)
7056 for(
int x = (UpStep + 1); x < DownStep; x++)
7065 for(
int x = (UpStep + 1); x < DownStep; x++)
7072 for(
int x = UpStep; x <= DownStep; x++)
7085 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
7092 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
7109 else if((RStep - LStep) == 1)
7128 for(
int x = (LStep + 1); x < RStep; x++)
7137 for(
int x = (LStep + 1); x < RStep; x++)
7144 for(
int x = LStep; x <= RStep; x++)
7163 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
7165 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7167 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
7170 if(BaseElementSpeedTag == 1)
7174 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
7181 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
7187 for(
int x = UpStep; x < (DownStep + 1); x++)
7202 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
7209 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
7215 for(
int x = LStep; x < (RStep + 1); x++)
7234 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7237 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7239 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
7241 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
7246 if(BaseElementSpeedTag == 1)
7250 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
7257 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
7263 for(
int x = UpStep; x <= DownStep; x++)
7277 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
7284 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
7290 for(
int x = LStep; x <= RStep; x++)
7306 Graphics::TBitmap *RouteGraphic;
7309 if(BaseElementSpeedTag == 1)
7311 if(TypeOfRoute == 1)
7315 else if(TypeOfRoute == 0)
7321 RouteGraphic = BaseGraphic;
7325 RouteGraphic = BaseGraphic;
7331 if(TypeOfRoute == 1)
7335 else if(TypeOfRoute == 0)
7341 RouteGraphic = BaseGraphic;
7345 RouteGraphic = BaseGraphic;
7350 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
7355 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
7359 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
7366 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
7369 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
7374 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
7379 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
7383 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
7390 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
7393 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
7518 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7522 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
7553 "," + AnsiString(VLoc));
7557 int DummyRouteNumber;
7559 TrainPresent =
false;
7563 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
7565 TrackMapKeyPair.first = HLoc;
7566 TrackMapKeyPair.second = VLoc + UpStep;
7567 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7576 TrainPresent =
true;
7590 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
7592 TrackMapKeyPair.first = HLoc;
7593 TrackMapKeyPair.second = VLoc + DownStep;
7594 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7603 TrainPresent =
true;
7617 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
7619 TrackMapKeyPair.first = HLoc + LeftStep;
7620 TrackMapKeyPair.second = VLoc;
7621 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7630 TrainPresent =
true;
7644 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
7646 TrackMapKeyPair.first = HLoc + RightStep;
7647 TrackMapKeyPair.second = VLoc;
7648 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
7657 TrainPresent =
true;
7677 for(
unsigned int x = 0; x < SearchVector.size(); x++)
7694 AnsiString(HLoc) +
"," + AnsiString(VLoc));
7697 throw Exception(
"PlotSmallFlashingLinkedLevelCrossings");
7703 while(
IsLCAtHV(61, HLoc, (VLoc + UpStep)))
7710 while(
IsLCAtHV(62, HLoc, (VLoc + DownStep)))
7716 for(
int x = UpStep; x <= DownStep; x++)
7723 while(
IsLCAtHV(63, (HLoc + LStep), VLoc))
7730 while(
IsLCAtHV(64, (HLoc + RStep), VLoc))
7736 for(
int x = LStep; x <= RStep; x++)
7752 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
7759 else if(TrackElement.
SpeedTag < 132)
7777 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7794 AnsiString(ScreenPosV));
7809 AnsiString(ScreenPosV));
7820 AnsiString(VPosTrue));
7834 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7846 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7847 " in TrackMap, Caller=" + (AnsiString)Caller);
7849 if(MapVecPos != (
int)a)
7851 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7852 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
7853 (AnsiString)Caller);
7859 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7860 " Caller=" + (AnsiString)Caller);
7880 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
7881 " in InactiveMap, Caller=" + (AnsiString)Caller);
7883 if((InactivePair.first != a) && (InactivePair.second != a))
7885 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
7886 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
7887 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
7892 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
7893 " Caller=" + (AnsiString)Caller);
7903 int Position1, Position2;
7909 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
7911 int HLoc1 = GapMapPtr->first.first;
7912 int VLoc1 = GapMapPtr->first.second;
7913 int HLoc2 = GapMapPtr->second.first;
7914 int VLoc2 = GapMapPtr->second.second;
7917 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
7921 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
7925 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
7929 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
7933 unsigned int GapCount = 0;
7935 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7943 if((
GapMap.size() * 2) != GapCount)
7945 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
7946 (AnsiString)Caller);
7956 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
7960 throw Exception(
"Error - TrackFinished with erase element still present");
7965 AnsiString IDString;
7967 if(TrackElement.
HLoc < 0)
7969 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
7973 IDString = AnsiString(TrackElement.
HLoc) +
"-";
7975 if(TrackElement.
VLoc < 0)
7977 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
7981 IDString += AnsiString(TrackElement.
VLoc);
7996 for(
int x = 1; x < String.Length() + 1; x++)
7998 if(String.IsDelimiter(
"-", x))
8003 if(x == String.Length())
8007 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
8017 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
8022 if(DelimPos == String.Length())
8026 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
8031 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
8035 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
8042 if(String.SubString(1, 1) !=
"N")
8044 for(
int x = 1; x < DelimPos; x++)
8046 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8050 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8057 if(String.SubString(1, 1) ==
"N")
8059 for(
int x = 2; x < DelimPos; x++)
8061 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8065 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
8072 if(String.SubString(1, 1) ==
"N")
8074 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
8078 HLoc = String.SubString(1, DelimPos - 1).ToInt();
8080 if(String.SubString(DelimPos + 1, 1) !=
"N")
8082 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
8084 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8088 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8095 if(String.SubString(DelimPos + 1, 1) ==
"N")
8097 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
8099 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
8103 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
8110 if(String.SubString(DelimPos + 1, 1) ==
"N")
8112 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
8116 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
8121 TrackMapPtr =
TrackMap.find(HVPair);
8126 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
8132 return(TrackMapPtr->second);
8134 catch(
const Exception &e)
8137 ShowMessage(
"Syntax error in track element identifier: <" + String +
">");
8151 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
8152 int HLoc = TrackElement.
HLoc;
8153 int VLoc = TrackElement.
VLoc;
8256 AnsiString(SpeedTag));
8267 if(HVRange.first == HVRange.second)
8274 HVIt1 = HVRange.first;
8279 if(--HVRange.second != HVRange.first)
8281 HVIt2 = HVRange.second;
8285 HVIt2->second).
SpeedTag == SpeedTag)))
8305 AnsiString(SpeedTag));
8371 AnsiString TestString1, TestString2;
8376 throw Exception(
"LNPendingList size not 1 on entry");
8378 int CurrentElementNumber;
8384 int H = CurrentElement->HLoc;
8385 int V = CurrentElement->VLoc;
8386 int Tag = CurrentElement->SpeedTag;
8392 for(
int x = 0; x < 25; x++)
8402 for(
int x = 0; x < 25; x++)
8412 for(
int x = 0; x < 25; x++)
8422 for(
int x = 0; x < 25; x++)
8432 for(
int x = 0; x < 28; x++)
8442 for(
int x = 0; x < 8; x++)
8452 for(
int x = 0; x < 8; x++)
8462 for(
int x = 0; x < 4; x++)
8472 for(
int x = 0; x < 8; x++)
8482 for(
int x = 0; x < 8; x++)
8495 if(CurrentElementNumber > -1)
8500 if((ExistingName !=
"") && (ExistingName != LocationName))
8516 AddName(1, CurrentElement, LocationName);
8520 LNDone2MultiMapEntry.first = HVPair;
8531 bool FoundFlag, ErasedFlag =
false;
8533 if(SNRange.first != SNRange.second)
8537 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
8544 TVIt->LocationName =
"";
8545 TVIt->ActiveTrackElementName =
"";
8578 std::pair<AnsiString, char>TempMapPair;
8586 TempMapPair.second =
'x';
8604 AnsiString(SpeedTag));
8614 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
8621 int MapPos = -1 - Position;
8625 FoundElement = MapPos;
8641 FoundElement = IMPair.first;
8650 FoundElement = IMPair.second;
8671 AnsiString OldName = TrackElement->LocationName, ErrorString;
8673 TrackElement->LocationName = Name;
8674 int HLoc = TrackElement->HLoc;
8675 int VLoc = TrackElement->VLoc;
8689 if(ErrorString !=
"")
8691 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
8715 if(LNDone2MultiMapIterator->second == MapPos)
8742 if(*LNPendingListIterator == MapPos)
8815 if(NameBeingChecked !=
"")
8821 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8829 NameBeingChecked = LNMMRg.second->first;
8831 if(NameBeingChecked !=
"")
8837 ShowMessage(
"Please note that more than one instance of " + NameBeingChecked +
" was found. Location names must be unique before the railway can be saved as a .rly file");
8858 if(LNMMIt->second < 0)
8868 HVPairsLinkedMap.insert(std::pair<THVPair, bool>(HVPair,
false));
8876 std::list<THVPair> HVLinkedList;
8879 HVPairsLinkedMap.begin()->second =
true;
8880 HVLinkedList.push_back(HVPairsLinkedMap.begin()->first);
8883 THVPair HVPairUnderExamination;
8884 THVPairsLinkedMap::iterator HVPLMIt;
8886 while(!HVLinkedList.empty())
8888 HVPairUnderExamination = HVLinkedList.front();
8889 HVLinkedList.pop_front();
8890 HVPairNew.first = HVPairUnderExamination.first;
8891 HVPairNew.second = HVPairUnderExamination.second - 1;
8892 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8893 if(HVPLMIt != HVPairsLinkedMap.end())
8895 if(!HVPLMIt->second)
8897 HVLinkedList.push_back(HVPLMIt->first);
8899 HVPLMIt->second =
true;
8901 HVPairNew.first = HVPairUnderExamination.first - 1;
8902 HVPairNew.second = HVPairUnderExamination.second;
8903 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8904 if(HVPLMIt != HVPairsLinkedMap.end())
8906 if(!HVPLMIt->second)
8908 HVLinkedList.push_back(HVPLMIt->first);
8910 HVPLMIt->second =
true;
8912 HVPairNew.first = HVPairUnderExamination.first;
8913 HVPairNew.second = HVPairUnderExamination.second + 1;
8914 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8915 if(HVPLMIt != HVPairsLinkedMap.end())
8917 if(!HVPLMIt->second)
8919 HVLinkedList.push_back(HVPLMIt->first);
8921 HVPLMIt->second =
true;
8923 HVPairNew.first = HVPairUnderExamination.first + 1;
8924 HVPairNew.second = HVPairUnderExamination.second;
8925 HVPLMIt = HVPairsLinkedMap.find(HVPairNew);
8926 if(HVPLMIt != HVPairsLinkedMap.end())
8928 if(!HVPLMIt->second)
8930 HVLinkedList.push_back(HVPLMIt->first);
8932 HVPLMIt->second =
true;
8937 for(THVPairsLinkedMap::iterator HVPLMIt = HVPairsLinkedMap.begin(); HVPLMIt != HVPairsLinkedMap.end(); HVPLMIt++)
8939 if(!HVPLMIt->second)
8958 if(LocationName ==
"")
8969 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8976 ActiveTrackElementNameMapEntry.second = 0;
8998 bool FoundFlag, ErasedFlag =
false;
9002 if(SNRange.first != SNRange.second)
9005 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9008 TVIt->LocationName =
"";
9009 TVIt->ActiveTrackElementName =
"";
9043 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
9045 AnsiString LocationName;
9054 if(LocationName !=
"")
9062 if(LocationName !=
"")
9076 if(LocationName !=
"")
9078 int ModifiedPosition = -1 - Position;
9087 for(
int x = 0; x < 25; x++)
9097 else if(SpeedTag == 77)
9099 for(
int x = 0; x < 25; x++)
9109 else if(SpeedTag == 78)
9111 for(
int x = 0; x < 25; x++)
9121 else if(SpeedTag == 79)
9123 for(
int x = 0; x < 25; x++)
9133 else if(SpeedTag == 96)
9135 for(
int x = 0; x < 28; x++)
9145 else if(SpeedTag == 129)
9147 for(
int x = 0; x < 8; x++)
9157 else if(SpeedTag == 130)
9159 for(
int x = 0; x < 8; x++)
9169 else if(SpeedTag == 145)
9171 for(
int x = 0; x < 8; x++)
9181 else if(SpeedTag == 146)
9183 for(
int x = 0; x < 8; x++)
9193 else if(SpeedTag == 131)
9195 for(
int x = 0; x < 4; x++)
9218 AnsiString(SpeedTag));
9230 if(TempElement->LocationName !=
"")
9232 LocationName = TempElement->LocationName;
9233 FoundElement = IMPair.first;
9241 if(TempElement->LocationName !=
"")
9243 LocationName = TempElement->LocationName;
9244 FoundElement = IMPair.second;
9256 if(TempElement->LocationName !=
"")
9258 LocationName = TempElement->LocationName;
9259 FoundElement = -1 - Position;
9275 unsigned int Count = 0;
9282 AnsiString SName, TName, ErrorString;
9284 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9290 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
9291 AnsiString(Caller));
9304 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
9305 AnsiString(Caller));
9312 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
9313 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9318 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9324 if(ErrorString !=
"")
9326 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
9328 if(SNIt->second != -1 - (
int)x)
9330 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9331 AnsiString(Caller));
9337 bool FoundFlag =
false;
9346 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackElementAt(1369, x).HLoc) +
" & V " +
9347 AnsiString(
TrackElementAt(1370, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9351 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackElementAt(1371, x).HLoc) +
9352 " & V " + AnsiString(
TrackElementAt(1372, x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
9353 AnsiString(Caller));
9358 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackElementAt(1373, x).HLoc) +
" & V " +
9359 AnsiString(
TrackElementAt(1374, x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
9369 if(ErrorString !=
"")
9371 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
9373 if(SNIt->second != (
int)x)
9375 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
9376 AnsiString(Caller));
9386 AnsiString &ErrorString)
9394 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
9396 bool FoundFlag =
false;
9400 if(SNRange.first == SNRange.second)
9402 ErrorString =
"Error, Name " + LocationName +
" not found in map";
9404 return(SNRange.first);
9408 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9410 if(SNIterator->second < 0)
9412 int TVPos = -1 - SNIterator->second;
9414 if(TVIt == TrackElement)
9423 int ITVPos = SNIterator->second;
9425 if(ITVIt == TrackElement)
9436 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
9453 LocationNameEntry.first = NewName;
9454 LocationNameEntry.second = SNIterator->second;
9468 int TruePos = -1 - Position;
9472 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9482 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
9505 InactiveTrack2MultiMapIterator++)
9507 if(InactiveTrack2MultiMapIterator->second > VecPos)
9509 InactiveTrack2MultiMapIterator->second--;
9517 LocationNameMultiMapIterator++)
9519 if(LocationNameMultiMapIterator->second < 0)
9523 if(LocationNameMultiMapIterator->second > (
int)VecPos)
9525 LocationNameMultiMapIterator->second--;
9547 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
9549 if(TrackMapIterator->second > VecPos)
9551 TrackMapIterator->second--;
9559 LocationNameMultiMapIterator++)
9561 if(LocationNameMultiMapIterator->second >= 0)
9567 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
9569 LocationNameMultiMapIterator->second++;
9573 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9579 if(TkEl.
Conn[0] ==
int(VecPos))
9584 if(TkEl.
Conn[0] >
int(VecPos))
9588 if(TkEl.
Conn[0] > -1)
9614 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
9620 LocationNameEntry.second = -1 - TVPos;
9631 LocationNameEntry.second = ITVPos;
9673 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9705 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9733 AnsiString((
short)FirstTrack));
9734 bool LengthDifferent =
false, SpeedDifferent =
false;
9741 int EXArray[16][2] =
9743 {2, 4}, {6, 2}, {8, 6}, {4, 8},
9744 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
9747 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
9748 Graphics::TBitmap *Bitmap;
9752 InLink = TrackElement.
Link[0];
9753 OutLink = TrackElement.
Link[1];
9757 InLink = TrackElement.
Link[2];
9758 OutLink = TrackElement.
Link[3];
9760 for(
int x = 0; x < 16; x++)
9762 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
9769 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLength");
9788 else if(TrackElement.
SpeedTag == 54)
9792 else if(TrackElement.
SpeedTag == 55)
9803 else if(TrackElement.
SpeedTag == 58)
9807 else if(TrackElement.
SpeedTag == 59)
9812 else if(Index == 14)
9818 else if(TrackElement.
SpeedTag == 52)
9822 else if(TrackElement.
SpeedTag == 57)
9827 else if(Index == 15)
9833 else if(TrackElement.
SpeedTag == 53)
9837 else if(TrackElement.
SpeedTag == 56)
9851 if(LengthDifferent && SpeedDifferent)
9919 else if(LengthDifferent && !SpeedDifferent)
10066 AnsiString((
short)FirstTrack));
10067 LengthDifferent =
false;
10068 SpeedDifferent =
false;
10073 LengthDifferent =
true;
10077 SpeedDifferent =
true;
10079 if(LengthDifferent || SpeedDifferent)
10092 LengthDifferent =
true;
10096 SpeedDifferent =
true;
10098 if(LengthDifferent || SpeedDifferent)
10111 LengthDifferent =
true;
10115 SpeedDifferent =
true;
10117 if(LengthDifferent || SpeedDifferent)
10197 AnsiString TempName;
10198 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
10199 bool ForwardSet, ReverseSet;
10201 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10206 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10208 ForwardSet =
false;
10209 ReverseSet =
false;
10244 for(
int y = 0; y < 2; y++)
10275 StartElement = TempElement;
10276 StartVecPos = VecPos;
10279 EntryPos = 1 - Dir;
10280 StartEntryPos = 1 - Dir;
10289 VecPos = TempElement.
Conn[1 - EntryPos];
10290 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10292 EntryPos = TempEntryPos;
10320 ForwardNumber = ((Count + 1) / 2) + 1;
10321 ReverseNumber = (Count - ForwardNumber) + 1;
10323 EntryPos = 1 - Dir;
10324 TempElement = StartElement;
10325 VecPos = StartVecPos;
10326 if(Count == ForwardNumber)
10331 if(Count == ReverseNumber)
10339 VecPos = TempElement.
Conn[1 - EntryPos];
10340 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
10342 EntryPos = TempEntryPos;
10344 if(Count == ForwardNumber)
10349 if(Count == ReverseNumber)
10361 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10497 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10553 if((TextH / 16) - 1 <
HLocMin)
10557 if((TextH / 16) + 1 >
HLocMax)
10561 if((TextV / 16) - 1 <
VLocMin)
10565 if((TextV / 16) + 1 >
VLocMax)
10595 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
10596 bool &UserGraphicFoundFlag)
10599 TUserGraphicVector::iterator UserGraphicPtr;
10601 UserGraphicFoundFlag =
false;
10608 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
10609 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
10611 UserGraphicItem = x;
10612 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
10613 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
10614 UserGraphicFoundFlag =
true;
10632 int SpeedTag = TrackElement.
SpeedTag;
10636 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
10685 return(GraphicOutput);
10693 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10696 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
10709 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
10710 " in InactiveTrackElementAt");
10721 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
10723 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
10748 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10749 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
10753 if(SNRange.first == SNRange.second)
10758 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10760 if(SNIterator->second < 0)
10774 HVPair.first = InactiveElement.
HLoc;
10775 HVPair.second = InactiveElement.
VLoc;
10779 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNamedLocationLongEnoughForSplit (1)");
10781 int TVPos =
TrackMap.find(HVPair)->second;
10784 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
10790 FirstNamedExitPos = 0;
10792 SecondNamedElement =
TrackElementAt(561, FirstNamedElement.
Conn[FirstNamedExitPos]);
10794 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10795 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10798 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10800 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
10801 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10802 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10805 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10815 FirstNamedExitPos = 1;
10817 SecondNamedElement =
TrackElementAt(564, FirstNamedElement.
Conn[FirstNamedExitPos]);
10819 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10820 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10823 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10825 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
10826 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10827 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10830 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10846 int &FirstNamedLinkedElementPos,
int &SecondNamedLinkedElementPos)
10860 AnsiString(FirstNamedElementPos));
10861 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
10862 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
10864 SecondNamedElementPos = -1;
10865 FirstNamedLinkedElementPos = -1;
10866 SecondNamedLinkedElementPos = -1;
10870 if(SNRange.first == SNRange.second)
10875 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10877 if(SNIterator->second < 0)
10887 HVPair.first = InactiveElement.
HLoc;
10888 HVPair.second = InactiveElement.
VLoc;
10900 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in ThisNamedLocationLongEnoughForSplit (2)"
10904 int TVPos =
TrackMap.find(HVPair)->second;
10905 if(TVPos != FirstNamedElementPos)
10911 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
10917 FirstNamedExitPos = 0;
10919 SecondNamedElement =
TrackElementAt(568, FirstNamedElement.
Conn[FirstNamedExitPos]);
10921 FirstNamedLinkedElement =
TrackElementAt(569, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10922 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10925 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10927 SecondNamedLinkedElement =
TrackElementAt(570, SecondNamedElement.
Conn[SecondNamedExitPos]);
10928 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10929 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10932 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10934 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
10935 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
10936 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
10945 FirstNamedExitPos = 1;
10947 SecondNamedElement =
TrackElementAt(571, FirstNamedElement.
Conn[FirstNamedExitPos]);
10949 FirstNamedLinkedElement =
TrackElementAt(572, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
10950 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
10953 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
10955 SecondNamedLinkedElement =
TrackElementAt(573, SecondNamedElement.
Conn[SecondNamedExitPos]);
10956 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
10957 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
10960 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
10962 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
10963 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
10964 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
10985 if(SNRange.first != SNRange.second)
10987 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
10989 if(SNIterator->second < 0)
11011 "," + AnsiString(SpeedTag));
11022 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
11052 else if(SpeedTag == 69)
11078 else if(SpeedTag == 70)
11104 else if(SpeedTag == 71)
11141 AnsiString(NextEntryPos) +
"," + AnsiString(OwnTrainID));
11142 if(NextEntryPos < 0)
11155 if(NextEntryPos > 1)
11174 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
11186 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
11187 bool FoundFlag =
false;
11202 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
11203 bool FoundFlag =
false;
11228 VPosHi = 16 * VLocHi;
11229 VPosLo = 16 * VLocLo;
11248 AnsiString(EndTVPosition));
11259 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
11260 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
11261 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
11262 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
11264 if(Link0Squares <= Link1Squares)
11282 AnsiString(LinkPos));
11301 if((LinkPos == 1) && (TE.
Attribute == 0))
11306 else if(LinkPos == 1)
11312 else if((LinkPos == 3) && (TE.
Attribute == 1))
11317 else if(LinkPos == 3)
11324 else if(LinkPos == 0)
11329 else if(LinkPos == 1)
11334 else if(LinkPos == 2)
11339 else if(LinkPos == 3)
11344 throw Exception(
"Error, failure in GetExitPos");
11393 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
11397 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
11439 "," + AnsiString(DiagonalLinkNumber));
11444 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(8, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
TrainOnLink(9, HLoc - 1, VLoc, 9, TrainID)))
11449 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(10, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
TrainOnLink(11, HLoc, VLoc - 1, 9, TrainID)))
11454 if(((DiagonalLinkNumber == 3) &&
TrainOnLink(12, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(13, HLoc + 1, VLoc, 7, TrainID)))
11459 if(((DiagonalLinkNumber == 7) &&
TrainOnLink(14, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(15, HLoc, VLoc + 1, 3, TrainID)))
11475 AnsiString JustFileName =
"";
11480 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
11487 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
11506 typedef std::list<int> TNamePosList;
11507 TNamePosList NamePosList;
11508 typedef TNamePosList::iterator TNPLIt;
11510 typedef std::list<int> TOnePlatList;
11511 TOnePlatList OnePlatList;
11512 typedef TOnePlatList::iterator TOPLIt;
11515 NamePosList.clear();
11516 OnePlatList.clear();
11517 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
11519 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
11521 NamePosList.push_back(x);
11526 if(!NamePosList.empty())
11528 OnePlatList.push_back(NamePosList.back());
11529 NamePosList.pop_back();
11531 while(!OnePlatList.empty())
11533 TempInt = OnePlatList.front();
11536 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
11537 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
11539 OnePlatList.push_back(TempElement.
Conn[0]);
11540 NamePosList.erase(NPLIt);
11542 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
11543 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
11545 OnePlatList.push_back(TempElement.
Conn[1]);
11546 NamePosList.erase(NPLIt);
11549 OnePlatList.erase(OnePlatList.begin());
11550 if(OnePlatList.empty())
11553 if(!NamePosList.empty())
11555 OnePlatList.push_back(NamePosList.back());
11556 NamePosList.pop_back();
11572 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not signal in RepairFailedSignals");
11576 throw Exception(
"Signals not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedSignals");
11604 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not points in RepairFailedPoints");
11608 throw Exception(
"Points not failed at " + AnsiString(FPVIt->TVPos) +
" in RepairFailedPoints");
11634 throw Exception(
"Element at " + AnsiString(FPVIt->TVPos) +
" not simple in RepairFailedPoints");
11638 throw Exception(
"No TSR at " + AnsiString(FPVIt->TVPos) +
" in RepairTSR");
11660 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
11679 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
11694 throw Exception(
"Return value negative in call to LastElementNumber");
11706 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
11720 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
11732 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
11733 " in GetModifiablePrefDirElementAt");
11743 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
11745 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
11755 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
11757 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
11774 int TrackVectorPosition;
11825 FinishElement =
false;
11826 int TrackVectorPosition;
11848 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
11858 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
11881 for(
int x = 0; x < 4; x++)
11904 FinishElement =
true;
11912 for(
int x = 0; x < 4; x++)
11924 FinishElement =
true;
11932 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
11939 .ELinkPos] ==
Lead))
11955 FinishElement =
true;
11974 FinishElement =
true;
11993 FinishElement =
true;
12008 FinishElement =
true;
12017 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12033 FinishElement =
true;
12039 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
12062 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
12063 int VectorCount = 0;
12067 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
12069 for(
int x = 0; x < VectorCount; x++)
12076 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
12080 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
12081 SearchElement.
ELinkPos = NextELinkPos;
12102 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
12104 SearchElement.
XLinkPos = NextXLinkPos;
12130 for(
int x = 0; x < VectorCount; x++)
12142 for(
int x = 0; x < VectorCount; x++)
12156 for(
int x = 0; x < VectorCount; x++)
12170 for(
int x = 0; x < VectorCount; x++)
12180 for(
int x = 0; x < VectorCount; x++)
12191 SearchElement.
XLink = SearchElement.
Link[1];
12210 SearchElement.
XLink = SearchElement.
Link[3];
12223 for(
int x = 0; x < VectorCount; x++)
12238 XLinkPos = NextXLinkPos;
12239 CurrentTrackElement = SearchElement;
12258 throw Exception(
"Error, SearchVector empty");
12265 for(
int x = 0; x < 4; x++)
12318 throw Exception(
"Error in EntryExitNumber 1");
12337 if(PrefDirElement.
XLink == -1)
12349 if(PrefDirElement.
XLink != -1)
12353 throw Exception(
"Error in EntryExitNumber 2");
12391 LeadingPoints =
false;
12419 LeadingPoints =
true;
12435 AnsiString ErrorString;
12436 bool Error =
false;
12443 ErrorString =
"HLoc";
12449 ErrorString =
"VLoc";
12455 ErrorString =
"ELink";
12461 ErrorString =
"ELinkPos";
12467 ErrorString =
"XLink";
12473 ErrorString =
"XLinkPos";
12479 ErrorString =
"Tag";
12485 ErrorString =
"TrackVectorPosition";
12491 ErrorString =
"EXNumber";
12498 ErrorString =
"CheckCount";
12505 ErrorString =
"EntryGraphicPtr";
12511 ErrorString =
"EntryDirectionGraphicPtr";
12520 ErrorString =
"Last XLink not connected to this element";
12527 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
12551 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
12608 AnsiString((
short)BuildingPrefDir));
12611 if(PrefDirSize() == 0)
12616 for(
unsigned int x = 0; x < PrefDirSize(); x++)
12628 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
12640 if(x == (PrefDirSize() - 1))
12649 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
12651 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
12652 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
12653 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
12655 if(PrefDirSize() > 1)
12657 unsigned int LatestPos = PrefDirSize() - 1;
12658 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
12659 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
12660 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
12681 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12684 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12688 H = MMIT->first.first;
12689 V = MMIT->first.second;
12692 if(PrefDirPos0 > -1)
12696 if(PrefDirPos1 > -1)
12700 if(PrefDirPos2 > -1)
12704 if(PrefDirPos3 > -1)
12708 if(PrefDirPos3 > -1)
12724 else if(PrefDirPos2 > -1)
12766 else if(PrefDirPos1 > -1)
12789 else if(PrefDirPos0 > -1)
12808 int NumberOfPrefDirElements = 0;
12811 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12813 VecFile >> TempInt;
12816 VecFile >> TempInt;
12817 LoadPrefDirElement.
ELink = TempInt;
12818 VecFile >> TempInt;
12819 LoadPrefDirElement.
ELinkPos = TempInt;
12820 VecFile >> TempInt;
12821 LoadPrefDirElement.
XLink = TempInt;
12822 VecFile >> TempInt;
12823 LoadPrefDirElement.
XLinkPos = TempInt;
12824 VecFile >> TempInt;
12825 LoadPrefDirElement.
EXNumber = TempInt;
12826 VecFile >> TempInt;
12831 if(!(LoadPrefDirElement.
IsARoute))
12857 int NumberOfPrefDirElements = 0;
12860 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12862 VecFile >> TempInt;
12863 VecFile >> TempInt;
12866 VecFile >> TempInt;
12867 LoadPrefDirElement.
ELink = TempInt;
12868 VecFile >> TempInt;
12869 LoadPrefDirElement.
ELinkPos = TempInt;
12870 VecFile >> TempInt;
12871 LoadPrefDirElement.
XLink = TempInt;
12872 VecFile >> TempInt;
12873 LoadPrefDirElement.
XLinkPos = TempInt;
12874 VecFile >> TempInt;
12875 LoadPrefDirElement.
EXNumber = TempInt;
12876 VecFile >> TempInt;
12881 if(!(LoadPrefDirElement.
IsARoute))
12909 int NumberOfPrefDirElements = 0;
12912 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
12917 for(
int x = 0; x < NumberOfPrefDirElements; x++)
12924 VecFile >> TempInt;
12925 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
12930 VecFile >> TempInt;
12931 if((TempInt < -1) || (TempInt > 9))
12936 VecFile >> TempInt;
12937 if((TempInt < -1) || (TempInt > 3))
12942 VecFile >> TempInt;
12943 if((TempInt < -1) || (TempInt > 9))
12948 VecFile >> TempInt;
12949 if((TempInt < -1) || (TempInt > 3))
12954 VecFile >> TempInt;
12955 if((TempInt < -1) || (TempInt > 27))
12960 VecFile >> TempInt;
12968 VecFile >> TempInt;
12969 if((TempInt != 0) && (TempInt != 1))
12974 VecFile >> TempInt;
12975 if((TempInt != 0) && (TempInt != 1))
12980 VecFile >> TempInt;
12981 if((TempInt != 0) && (TempInt != 1))
13004 for(
int y = 0; y < NumberOfPrefDirElements; y++)
13006 VecFile << y <<
'\n';
13007 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
13017 if(y == (NumberOfPrefDirElements - 1))
13019 VecFile <<
"************" <<
'\0' <<
'\n';
13023 VecFile <<
"******" <<
'\0' <<
'\n';
13037 for(
int y = 0; y < NumberOfSearchElements; y++)
13039 VecFile << y <<
'\n';
13040 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
13050 if(y == (NumberOfSearchElements - 1))
13052 VecFile <<
"************" <<
'\0' <<
'\n';
13056 VecFile <<
"******" <<
'\0' <<
'\n';
13169 bool AlreadyPresent, FoundFlag;
13170 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
13172 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
13176 AlreadyPresent =
false;
13181 AlreadyPresent =
true;
13185 AlreadyPresent =
true;
13189 AlreadyPresent =
true;
13193 AlreadyPresent =
true;
13196 if(!AlreadyPresent)
13243 for(
unsigned int z = 0; z < 4; z++)
13251 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
13265 bool DiscrepancyFound =
false;
13276 DiscrepancyFound =
true;
13281 DiscrepancyFound =
true;
13286 DiscrepancyFound =
true;
13291 DiscrepancyFound =
true;
13296 DiscrepancyFound =
true;
13302 DiscrepancyFound =
true;
13305 if(DiscrepancyFound)
13307 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
13322 bool DiscrepancyFound =
false;
13333 DiscrepancyFound =
true;
13337 DiscrepancyFound =
true;
13342 DiscrepancyFound =
true;
13347 DiscrepancyFound =
true;
13352 DiscrepancyFound =
true;
13358 DiscrepancyFound =
true;
13362 return(!DiscrepancyFound);
13374 bool FoundFlag =
false;
13375 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
13383 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
13384 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
13386 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
13388 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
13389 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
13390 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
13395 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
13396 +
" Caller=" + (AnsiString)Caller);
13422 PrefDirMapKeyPair.first = HLoc;
13423 PrefDirMapKeyPair.second = VLoc;
13424 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13427 if(ItPair.first == ItPair.second)
13435 PrefDirPos0 = ItPair.first->second;
13437 if(ItPair.first == ItPair.second)
13442 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13444 PrefDirPos1 = ItPair.first->second;
13447 if(ItPair.first == ItPair.second)
13452 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13454 PrefDirPos2 = ItPair.first->second;
13457 if(ItPair.first == ItPair.second)
13462 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
13464 PrefDirPos3 = ItPair.first->second;
13479 +
"," + AnsiString(LinkNumberPos));
13481 int PD0, PD1, PD2, PD3;
13482 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
13486 PD0, PD1, PD2, PD3);
13498 LinkedPrefDirVectorNumber = PD0;
13507 LinkedPrefDirVectorNumber = PD1;
13517 LinkedPrefDirVectorNumber = PD0;
13526 LinkedPrefDirVectorNumber = PD1;
13535 LinkedPrefDirVectorNumber = PD2;
13544 LinkedPrefDirVectorNumber = PD3;
13549 LinkedPrefDirVectorNumber = -1;
13555 LinkedPrefDirVectorNumber = -1;
13560 catch(
const Exception &e)
13562 LinkedPrefDirVectorNumber = -1;
13577 +
"," + AnsiString(LinkNumberPos));
13579 int PD0, PD1, PD2, PD3;
13580 if(
PrefDirVector.at(PrefDirVectorNumber).Conn[LinkNumberPos] > -1)
13584 PD0, PD1, PD2, PD3);
13597 LinkedPrefDirVectorNumber = PD0;
13607 LinkedPrefDirVectorNumber = PD1;
13612 LinkedPrefDirVectorNumber = -1;
13620 LinkedPrefDirVectorNumber = PD0;
13629 LinkedPrefDirVectorNumber = PD1;
13638 LinkedPrefDirVectorNumber = PD2;
13647 LinkedPrefDirVectorNumber = PD3;
13652 LinkedPrefDirVectorNumber = -1;
13658 LinkedPrefDirVectorNumber = -1;
13663 catch(
const Exception &e)
13665 LinkedPrefDirVectorNumber = -1;
13677 int PD0, PD1, PD2, PD3;
13729 THVPair PrefDir4MultiMapKeyPair;
13732 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
13733 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
13734 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
13757 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
13776 AnsiString(ErasedElementNumber));
13781 if(MapPtr->second > ErasedElementNumber)
13803 throw Exception(
"PrefDirVectorPosition out of range");
13806 THVPair PrefDir4MultiMapKeyPair;
13808 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
13809 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
13810 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13813 if(ItPair.first == ItPair.second)
13816 return(ItPair.first);
13820 if(ItPair.first->second == PrefDirVectorPosition)
13824 return(ItPair.first);
13827 if(ItPair.first == ItPair.second)
13830 return(ItPair.first);
13832 if(ItPair.first->second == PrefDirVectorPosition)
13836 return(ItPair.first);
13839 if(ItPair.first == ItPair.second)
13842 return(ItPair.first);
13844 if(ItPair.first->second == PrefDirVectorPosition)
13848 return(ItPair.first);
13851 if(ItPair.first == ItPair.second)
13854 return(ItPair.first);
13856 if(ItPair.first->second == PrefDirVectorPosition)
13860 return(ItPair.first);
13864 return(ItPair.first);
13877 THVPair PrefDir4MultiMapKeyPair;
13879 PrefDir4MultiMapKeyPair.first = HLoc;
13880 PrefDir4MultiMapKeyPair.second = VLoc;
13881 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
13884 if(ItPair.first == ItPair.second)
13892 return(ItPair.first->second);
13901 bool ErasedFlag =
false;
13903 if(ErasedTrackVectorPosition > -1)
13912 ErasedFlag =
false;
13914 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
13919 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
13924 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
13929 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
13934 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
13942 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
13946 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
13950 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
13954 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
13958 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
13973 OverallDistance = 0;
13974 OverallSpeedLimit = 0;
13975 LeadingPointsAtLastElement =
false;
13983 LeadingPointsAtLastElement =
true;
13992 OverallDistance += PrefDirElement.
Length23;
13993 if(OverallSpeedLimit != -1)
14003 OverallSpeedLimit = -1;
14010 OverallDistance += PrefDirElement.
Length01;
14011 if(OverallSpeedLimit != -1)
14021 OverallSpeedLimit = -1;
14040 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14043 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14047 HLoc = MMIT->first.first;
14048 VLoc = MMIT->first.second;
14053 if(PrefDirPos0 > -1)
14057 if(PrefDirPos1 > -1)
14061 if(PrefDirPos2 > -1)
14065 if(PrefDirPos3 > -1)
14069 if(PrefDirPos3 > -1)
14072 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14074 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14076 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14078 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
14085 else if(PrefDirPos2 > -1)
14090 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14092 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14094 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
14103 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14105 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14107 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
14116 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14118 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
14120 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14127 else if(PrefDirPos1 > -1)
14132 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
14134 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
14142 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14144 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
14150 else if(PrefDirPos0 > -1)
14152 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
14169 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14172 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
14194 if(PrefDirPos0 > -1)
14198 if(PrefDirPos1 > -1)
14202 if(PrefDirPos2 > -1)
14206 if(PrefDirPos3 > -1)
14210 if(PrefDirPos3 > -1)
14215 else if(PrefDirPos2 > -1)
14217 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
14228 else if(PrefDirPos1 > -1)
14230 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
14241 else if(PrefDirPos0 > -1)
14243 if(PrefDirElement0.
XLinkPos == EntryPos)
14280 ElementIn.
VLoc +
"," + XLink);
14282 bool TrackFoundFlag;
14285 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
14297 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
14307 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
14321 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
14331 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
14345 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
14355 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
14369 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
14379 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
14402 bool FoundFlag, ContFlag, FoundElements =
false;
14403 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
14408 LastIteratorValue++;
14434 if(PDVIt->XLinkPos == 0)
14439 StartElement = *PDVIt;
14448 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
14450 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14451 if(PrefDirPos0 == -1)
14455 bool NextElementFoundFlag =
false;
14459 NextElementFoundFlag =
true;
14461 if(PrefDirPos1 > -1)
14466 NextElementFoundFlag =
true;
14469 if(PrefDirPos2 > -1)
14474 NextElementFoundFlag =
true;
14477 if(PrefDirPos3 > -1)
14482 NextElementFoundFlag =
true;
14485 if(!NextElementFoundFlag)
14515 EndElement = NextElement;
14519 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
14521 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14522 if(PrefDirPos0 == -1)
14532 if(PrefDirPos1 > -1)
14540 if(PrefDirPos2 > -1)
14548 if(PrefDirPos3 > -1)
14579 FoundElements =
true;
14613 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
14615 int TrackVectorPosition;
14651 int LockedVectorNumber;
14674 bool InPrefDirFlag =
false;
14677 int PrefDirPos0 = -1;
14678 int PrefDirPos1 = -1;
14679 int PrefDirPos2 = -1;
14680 int PrefDirPos3 = -1;
14684 int PrefDirVecPos[4] =
14686 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14689 for(
int x = 0; x < 4; x++)
14691 int b = PrefDirVecPos[x];
14701 InPrefDirFlag =
true;
14714 TrainController->
StopTTClockMessage(12,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
14722 if(DummyPair.first > -1)
14724 throw Exception(
"Selection in two routes - should never happen!");
14726 if(RoutePair.first > -1)
14802 IDInt &ReqPosRouteID,
bool &PointsChanged)
14836 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignals) +
"," + AnsiString((
short)AutoSigsFlag));
14838 int NewFailedPointsTVPos = -1;
14887 bool InPrefDirFlag =
false;
14890 int PrefDirPos0 = -1;
14891 int PrefDirPos1 = -1;
14892 int PrefDirPos2 = -1;
14893 int PrefDirPos3 = -1;
14896 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
14897 int PrefDirVecPos[4] =
14899 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
14902 for(
int x = 0; x < 4; x++)
14904 int b = PrefDirVecPos[x];
14907 InPrefDirFlag =
true;
14920 TrainController->
StopTTClockMessage(23,
"Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
14929 if(RoutePair.first > -1)
14931 if(RoutePair.second != 0)
14948 EndElement1 = RouteElement;
14949 EndElement2 = BlankElement;
15044 AutoSigsFlag,
false))
15049 if(NewFailedPointsTVPos > -1)
15053 " failed during route setting.");
15057 PointsChanged =
true;
15080 AutoSigsFlag,
false))
15085 if(NewFailedPointsTVPos > -1)
15089 " failed during route setting.");
15093 PointsChanged =
true;
15111 AutoSigsFlag,
false))
15116 if(NewFailedPointsTVPos > -1)
15120 " failed during route setting.");
15124 PointsChanged =
true;
15148 AutoSigsFlag,
false))
15153 if(NewFailedPointsTVPos > -1)
15157 " failed during route setting.");
15161 PointsChanged =
true;
15170 AutoSigsFlag,
false))
15175 if(NewFailedPointsTVPos > -1)
15179 " failed during route setting.");
15183 PointsChanged =
true;
15194 AutoSigsFlag,
false))
15199 if(NewFailedPointsTVPos > -1)
15203 " failed during route setting.");
15207 PointsChanged =
true;
15213 AutoSigsFlag,
false))
15218 if(NewFailedPointsTVPos > -1)
15222 " failed during route setting.");
15226 PointsChanged =
true;
15237 AutoSigsFlag,
false))
15242 if(NewFailedPointsTVPos > -1)
15246 " failed during route setting.");
15250 PointsChanged =
true;
15304 TOnePrefDir *EveryPrefDir,
bool ConsecSignals,
int EndPosition,
bool AutoSigsFlag,
bool RecursiveCall)
15356 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
15357 AnsiString((
short)AutoSigsFlag));
15358 int VectorCount = 0;
15362 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
15366 for(
int x = 0; x < VectorCount; x++)
15374 bool FirstPass =
true;
15384 for(
int x = 0; x < VectorCount; x++)
15393 for(
int x = 0; x < VectorCount; x++)
15405 for(
int x = 0; x < VectorCount; x++)
15413 int NextPosition = PrefDirElement.
Conn[XLinkPos];
15417 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
15418 SearchElement.
ELinkPos = NextELinkPos;
15419 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
15440 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
15442 SearchElement.
XLinkPos = NextXLinkPos;
15455 for(
int x = 0; x < VectorCount; x++)
15469 if(RoutePair.first > -1)
15478 for(
int x = 0; x < VectorCount; x++)
15487 if(SecondPair.first > -1)
15496 for(
int x = 0; x < VectorCount; x++)
15510 for(
int x = 0; x < VectorCount; x++)
15521 for(
int x = 0; x < VectorCount; x++)
15530 for(
int x = 0; x < VectorCount; x++)
15539 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15543 for(
int x = 0; x < VectorCount; x++)
15553 bool InPrefDirFlag =
false;
15554 PrefDirElement1 = BlankElement;
15555 PrefDirElement2 = BlankElement;
15558 int PrefDirPos0 = -1;
15559 int PrefDirPos1 = -1;
15560 int PrefDirPos2 = -1;
15561 int PrefDirPos3 = -1;
15564 int PrefDirVecPos[4] =
15566 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3
15568 for(
int x = 0; x < 4; x++)
15570 int b = PrefDirVecPos[x];
15573 InPrefDirFlag =
true;
15586 for(
int x = 0; x < VectorCount; x++)
15598 for(
int x = 0; x < VectorCount; x++)
15613 for(
int x = 0; x < VectorCount; x++)
15633 for(
int x = 0; x < VectorCount; x++)
15645 for(
int x = 0; x < VectorCount; x++)
15659 for(
int x = 0; x < VectorCount; x++)
15669 for(
int x = 0; x < VectorCount; x++)
15700 for(
int x = 0; x < VectorCount; x++)
15709 for(
int x = 0; x < VectorCount; x++)
15721 int SearchPos1 = SearchElement.
Attribute + 1;
15723 if(SearchPos1 == 2)
15727 if(SearchPos1 == 1)
15735 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
15736 SearchElement.
XLinkPos = SearchPos1;
15737 InPrefDirFlag =
false;
15738 if(SearchElement.
XLink == PrefDirElement1.
XLink)
15740 SearchElement = PrefDirElement1;
15741 InPrefDirFlag =
true;
15743 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
15745 SearchElement = PrefDirElement2;
15746 InPrefDirFlag =
true;
15752 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15756 for(
int x = 0; x < VectorCount; x++)
15774 AutoSigsFlag,
true))
15783 for(
int x = 0; x < VectorCount; x++)
15792 for(
int x = 0; x < VectorCount; x++)
15810 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
15811 SearchElement.
XLinkPos = SearchPos2;
15812 if(SearchElement.
XLink == PrefDirElement1.
XLink)
15814 SearchElement = PrefDirElement1;
15816 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
15818 SearchElement = PrefDirElement2;
15822 for(
int x = 0; x < VectorCount; x++)
15830 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15834 for(
int x = 0; x < VectorCount; x++)
15853 AutoSigsFlag,
true))
15862 for(
int x = 0; x < VectorCount; x++)
15871 for(
int x = 0; x < VectorCount; x++)
15883 for(
int x = 0; x < VectorCount; x++)
15893 SearchElement = PrefDirElement1;
15902 XLinkPos = SearchElement.
XLinkPos;
15903 PrefDirElement = SearchElement;
15960 unsigned int TruncatePrefDirPosition = 0;
16033 throw Exception(
"Error - failed to validate extended route for preferred route");
16088 throw Exception(
"Error - failed to validate single route for preferred route");
16133 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
16135 int TrackVectorPosition;
16172 int LockedVectorNumber;
16206 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
16207 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
16210 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
16216 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
16217 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
16220 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
16234 if(RoutePair.first > -1)
16369 int NewFailedPointsTVPos = -1;
16434 EndElement1.
ELink = EndElement1.
Link[0];
16435 EndElement1.
XLink = EndElement1.
Link[1];
16438 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
16443 EndElement2.
ELink = EndElement2.
Link[1];
16444 EndElement2.
XLink = EndElement2.
Link[0];
16447 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
16491 if(RoutePair.first > -1)
16493 if(RoutePair.second != 0)
16516 EndElement2 = BlankElement;
16601 if(NewFailedPointsTVPos > -1)
16605 " failed during route setting.");
16609 PointsChanged =
true;
16635 if(NewFailedPointsTVPos > -1)
16639 " failed during route setting.");
16643 PointsChanged =
true;
16665 if(NewFailedPointsTVPos > -1)
16669 " failed during route setting.");
16673 PointsChanged =
true;
16699 if(NewFailedPointsTVPos > -1)
16703 " failed during route setting.");
16707 PointsChanged =
true;
16721 if(NewFailedPointsTVPos > -1)
16725 " failed during route setting.");
16729 PointsChanged =
true;
16769 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
16770 int VectorCount = 0;
16773 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
16774 (CurrentTrackElement.
Link[XLinkPos] == 9))
16778 for(
int x = 0; x < VectorCount; x++)
16790 for(
int x = 0; x < VectorCount; x++)
16797 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
16799 for(
int x = 0; x < VectorCount; x++)
16806 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
16810 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
16811 SearchElement.
ELinkPos = NextELinkPos;
16832 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
16834 SearchElement.
XLinkPos = NextXLinkPos;
16847 for(
int x = 0; x < VectorCount; x++)
16861 if(RoutePair.first > -1)
16870 for(
int x = 0; x < VectorCount; x++)
16879 if(SecondPair.first > -1)
16888 for(
int x = 0; x < VectorCount; x++)
16902 for(
int x = 0; x < VectorCount; x++)
16913 for(
int x = 0; x < VectorCount; x++)
16922 for(
int x = 0; x < VectorCount; x++)
16931 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
16935 for(
int x = 0; x < VectorCount; x++)
16948 for(
int x = 0; x < VectorCount; x++)
16976 for(
int x = 0; x < VectorCount; x++)
16989 for(
int x = 0; x < VectorCount; x++)
16999 for(
int x = 0; x < VectorCount; x++)
17024 for(
int x = 0; x < VectorCount; x++)
17033 for(
int x = 0; x < VectorCount; x++)
17046 int SearchPos1 = SearchElement.
Attribute + 1;
17048 if(SearchPos1 == 2)
17052 if(SearchPos1 == 1)
17061 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
17062 SearchElement.
XLinkPos = SearchPos1;
17064 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17068 for(
int x = 0; x < VectorCount; x++)
17086 for(
int x = 0; x < VectorCount; x++)
17102 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
17103 SearchElement.
XLinkPos = SearchPos2;
17105 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
17109 for(
int x = 0; x < VectorCount; x++)
17125 for(
int x = 0; x < VectorCount; x++)
17137 for(
int x = 0; x < VectorCount; x++)
17152 CurrentTrackElement = SearchElement;
17153 XLinkPos = SearchElement.
XLinkPos;
17175 throw Exception(
"Error, SearchVector empty");
17187 for(
int x = 0; x < 4; x++)
17229 throw Exception(
"Error in EntryExitNumber 3");
17284 unsigned int TruncatePrefDirPosition = 0;
17344 throw Exception(
"Failed to validate extended route for nonpreferred route");
17389 throw Exception(
"Failed to validate single route for nonpreferred route");
17409 if(!PrefDirVector.empty())
17413 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
17418 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
17453 if(!PrefDirVector.empty())
17456 TPrefDirElement LastElement = GetFixedPrefDirElementAt(185, PrefDirSize() - 1);
17458 int ForwardLinkedRouteNumber, Attribute = 0;
17465 if(ForwardLinkedRouteNumber > -1)
17467 int NextForwardLinkedRouteNumber = -1;
17471 ForwardLinkedRouteNumber = NextForwardLinkedRouteNumber;
17482 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
17499 NewFailedPointsTVPos = -1;
17500 bool PointsChanged =
false;
17508 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
17518 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
17519 IFE.
TVPos = NewFailedPointsTVPos;
17538 PointsChanged =
true;
17541 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
17551 NewFailedPointsTVPos = SearchPtr->TrackVectorPosition;
17552 IFE.
TVPos = NewFailedPointsTVPos;
17571 PointsChanged =
true;
17577 return(PointsChanged);
17598 NextForwardLinkedRouteNumber = -1;
17599 for(
unsigned int x = 0; x < PrefDirSize(); x++)
17601 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
17602 if(PrefDirVector.at(x).TrackType ==
Bridge)
17604 if(PrefDirVector.at(x).XLinkPos < 2)
17606 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit01;
17610 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeOrFailedPointOrigSpeedLimit23;
17618 if(PrefDirVector.at(x).TrackType ==
Buffers)
17630 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
17639 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
17641 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute;
17653 if(x == PrefDirSize() - 1)
17697 AnsiString(PrefDirVectorStartPosition));
17702 bool SkipContinuationAndBufferAttributeChange =
false;
17704 if(!PrefDirVector.empty())
17706 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
17709 if(PrefDirPtr->TrackType ==
Bridge)
17711 if(PrefDirPtr->XLinkPos < 2)
17722 SkipContinuationAndBufferAttributeChange =
true;
17737 SkipContinuationAndBufferAttributeChange =
true;
17745 SkipContinuationAndBufferAttributeChange =
true;
17747 if(!SkipContinuationAndBufferAttributeChange)
17749 if(PrefDirVector.back().TrackType ==
Buffers)
17758 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
17761 if(PrefDirPtr->TrackType ==
Bridge)
17763 if(PrefDirPtr->XLinkPos < 2)
17779 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
17788 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
17791 PrefDirPtr->PrefDirRoute)
17795 int LockedVecNum = 0;
17797 bool KeepAttributeAt0ForLockedRoute =
false;
17802 KeepAttributeAt0ForLockedRoute =
true;
17807 bool NotGroundSignal =
false;
17810 NotGroundSignal =
true;
17835 if((Attribute < 3) && !KeepAttributeAt0ForLockedRoute && (NotGroundSignal || (Attribute == 0)))
17864 "," + AnsiString((
short)PrefDirRoute));
17865 bool ElementInRoute =
false;
17866 bool MovingTrainOccupyingRoute =
false;
17867 unsigned int TruncatePDElementPos;
17868 enum {NoTruncate, BackTruncate, FrontTruncate, FullTruncate} TruncateType;
17869 TruncateType = NoTruncate;
17876 TruncatePDElementPos = b;
17877 ElementInRoute =
true;
17881 if(!ElementInRoute)
17891 if(TruncatePDElementPos == 0)
17893 TruncateType = FullTruncate;
17900 TruncateType = FrontTruncate;
17904 TruncateType = BackTruncate;
17912 TruncateType = BackTruncate;
17918 if(TruncateType == BackTruncate)
17938 MovingTrainOccupyingRoute =
true;
17949 if(b ==
int(TruncatePDElementPos))
17955 else if(TruncateType == FrontTruncate)
17975 MovingTrainOccupyingRoute =
true;
17986 if(b == TruncatePDElementPos)
18012 MovingTrainOccupyingRoute =
true;
18034 if(((TruncatePDElementPos == 1) && (TruncateType == BackTruncate)) || ((TruncatePDElementPos == (
PrefDirSize() - 2)) && (TruncateType == FrontTruncate)))
18043 if((TruncatePDElementPos > 0) && (TruncateType == BackTruncate))
18050 TrainController->
StopTTClockMessage(145,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18051 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18052 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18072 else if((TruncatePDElementPos < (
PrefDirSize() - 1)) && (TruncateType == FrontTruncate))
18079 TrainController->
StopTTClockMessage(146,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18080 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18081 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18090 if(TruncatePDElementPos > 0)
18105 else if(TruncatePDElementPos == 0)
18112 TrainController->
StopTTClockMessage(148,
"Invalid green or blue route truncation position:\n\nto truncate from the start of the route select a position immediately before a facing signal "
18113 "that lies within the route;\n\nto truncate to the end of the route select a position immediately after a facing signal "
18114 "that lies within the route;\n\nor to remove the whole route select the first track element in the route");
18134 int ThisRouteNumber;
18144 if(LRVIT->RouteNumber == ThisRouteNumber)
18155 unsigned int LookBackwardsFromHere = 0;
18156 if(TruncateType == BackTruncate)
18158 LookBackwardsFromHere = TruncatePDElementPos;
18170 int button = Application->MessageBox(L
"Moving train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
18171 L
"Warning!", MB_YESNO | MB_ICONWARNING);
18184 bool ExistingLockedRouteModified =
false;
18186 if(TruncateType == BackTruncate)
18192 else if(TruncateType == FrontTruncate)
18213 if(LRVIT->RouteNumber == ThisRouteNumber)
18217 ExistingLockedRouteModified =
true;
18221 if(!ExistingLockedRouteModified)
18225 if(TruncateType == BackTruncate)
18228 RearPosition = TruncatePDElementPos;
18231 else if(TruncateType == FrontTruncate)
18235 FrontPosition = TruncatePDElementPos;
18244 for(
int c = FrontPosition; c >= RearPosition; c--)
18262 if(TruncateType == BackTruncate)
18264 RearPosition = TruncatePDElementPos;
18268 else if(TruncateType == FrontTruncate)
18271 FrontPosition = TruncatePDElementPos;
18288 for(
int c = FrontPosition; c >= RearPosition; c--)
18332 TPrefDirElement NewGreenFirstPDElement, NewRedFirstPDElement, NewGreenLastPDElement, NewRedLastPDElement;
18345 if(RouteColour == 1)
18347 NewRedFirstPDElement = LastPDElement;
18351 NewRedFirstPDElement.
IsARoute =
true;
18357 if(R2MMIt->second.first ==
int(x))
18359 R2MMIt->second.second++;
18366 else if(RouteColour == 2)
18368 NewGreenFirstPDElement = LastPDElement;
18372 NewGreenFirstPDElement.
IsARoute =
true;
18378 if(R2MMIt->second.first ==
int(x))
18380 R2MMIt->second.second++;
18403 if(RouteColour == 1)
18405 NewRedLastPDElement = FirstPDElement;
18414 else if(RouteColour == 2)
18416 NewGreenLastPDElement = FirstPDElement;
18493 AnsiString((
short)PrefDirRoute));
18518 AnsiString((
short)PrefDirRoute));
18528 RouteFlashElement.
HLoc = H;
18529 RouteFlashElement.
VLoc = V;
18545 int H = PrefDirPtr->HLoc;
18546 int V = PrefDirPtr->VLoc;
18613 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
18619 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
18622 OverlayPlotted =
false;
18645 bool FirstSignalFound =
false;
18652 if(PDVIt->TrackType ==
Points)
18654 if((PDVIt->ELinkPos == 1) || (PDVIt->XLinkPos == 1))
18665 else if((PDVIt->ELinkPos == 3) || (PDVIt->XLinkPos == 3))
18680 int XLinkPosition = PDVIt->XLinkPos;
18681 if(PDVIt->XLinkPos == -1)
18685 for(
int x = 0; x < 4; x++)
18687 if(PDVIt->Conn[x] == (PDVIt + 1)->TrackVectorPosition)
18700 if(XLinkPosition > -1)
18702 if(!FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
18704 FirstSignalFound =
true;
18707 else if(FirstSignalFound && (PDVIt->Config[XLinkPosition] ==
Signal))
18718 IFE.
TVPos = PDVIt->TrackVectorPosition;
18724 " failed when changing aspect.\nTrains can only pass under signaller control.");
18754 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
18756 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
18759 return(AllRoutesVector.at(At));
18767 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
18769 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
18772 return(AllRoutesVector.at(At));
18783 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18785 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
18795 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18797 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
18815 AnsiString(VLoc) +
"," + AnsiString((
short)PrefDirRoute));
18816 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
18820 GetModifiableRouteAt(7, a).TruncateRoute(0, HLoc, VLoc, PrefDirRoute, ReturnFlag);
18849 AnsiString(LinkPos));
18850 if(TrackVectorPosition == -1)
18855 THVPair Route2MultiMapKeyPair;
18859 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
18862 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
18872 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
18874 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
18877 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
18878 Route2MultiMapIterator->second.second);
18879 EntryLinkPos = PrefDirElement1.
ELinkPos;
18880 ExitLinkPos = PrefDirElement1.
XLinkPos;
18881 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
18882 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
18894 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
18906 Graphics::TBitmap* &EntryDirectionGraphicPtr)
18916 AnsiString(LinkPos));
18919 if(TrackVectorPosition == -1)
18924 THVPair Route2MultiMapKeyPair;
18928 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
18931 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
18936 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
18938 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
18940 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
18941 Route2MultiMapIterator->second.second);
18942 EntryLinkPos = PrefDirElement1.
ELinkPos;
18943 ExitLinkPos = PrefDirElement1.
XLinkPos;
18944 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
18945 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
18949 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
18950 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
18957 return(AutoSigsRoute);
18962 return(NotAutoSigsRoute);
18968 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
18969 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
18976 return(AutoSigsRoute);
18981 return(NotAutoSigsRoute);
18985 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
18987 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
18988 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
18990 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
18991 EntryLinkPos = PrefDirElement2.
ELinkPos;
18992 ExitLinkPos = PrefDirElement2.
XLinkPos;
18993 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
18994 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
18998 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
19005 return(AutoSigsRoute);
19010 return(NotAutoSigsRoute);
19016 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
19023 return(AutoSigsRoute);
19028 return(NotAutoSigsRoute);
19032 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
19033 EntryLinkPos = PrefDirElement3.
ELinkPos;
19034 ExitLinkPos = PrefDirElement3.
XLinkPos;
19035 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
19036 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
19040 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
19047 return(AutoSigsRoute);
19052 return(NotAutoSigsRoute);
19058 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
19065 return(AutoSigsRoute);
19070 return(NotAutoSigsRoute);
19086 AnsiString(LinkPos));
19087 if(TrackVectorPosition == -1)
19093 THVPair Route2MultiMapKeyPair;
19097 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
19100 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19106 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19108 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19110 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
19111 Route2MultiMapIterator->second.second);
19112 EntryLinkPos = PrefDirElement1.
ELinkPos;
19113 ExitLinkPos = PrefDirElement1.
XLinkPos;
19114 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
19115 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
19118 RouteNumber = Route2MultiMapIterator->second.first;
19122 return(AutoSigsRoute);
19127 return(NotAutoSigsRoute);
19132 RouteNumber = Route2MultiMapIterator->second.first;
19136 return(AutoSigsRoute);
19141 return(NotAutoSigsRoute);
19145 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19147 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19148 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19150 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
19151 EntryLinkPos = PrefDirElement2.
ELinkPos;
19152 ExitLinkPos = PrefDirElement2.
XLinkPos;
19153 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
19154 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
19157 RouteNumber = ItPair.first->second.first;
19161 return(AutoSigsRoute);
19166 return(NotAutoSigsRoute);
19171 RouteNumber = ItPair.first->second.first;
19175 return(AutoSigsRoute);
19180 return(NotAutoSigsRoute);
19184 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
19185 EntryLinkPos = PrefDirElement3.
ELinkPos;
19186 ExitLinkPos = PrefDirElement3.
XLinkPos;
19187 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
19188 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
19191 RouteNumber = ItPair.second->second.first;
19195 return(AutoSigsRoute);
19200 return(NotAutoSigsRoute);
19205 RouteNumber = ItPair.second->second.first;
19209 return(AutoSigsRoute);
19214 return(NotAutoSigsRoute);
19236 EmptyRoute.
RouteID = NextRouteID;
19239 AllRoutesVector.push_back(EmptyRoute);
19240 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
19265 AllRoutesVector.push_back(EmptyRoute);
19266 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
19289 THVPair Route2MultiMapKeyPair;
19298 LockedRouteRearTrackVectorPosition = 0;
19299 LockedRouteLastTrackVectorPosition = 0;
19300 LockedRouteLastXLinkPos = 0;
19301 LockedRouteLockStartTime = TDateTime(0);
19302 if(!LockedRouteVector.empty())
19306 if(LRVIT->RouteNumber == RouteNumber)
19308 LockedRouteRearTrackVectorPosition = LRVIT->RearTrackVectorPosition;
19309 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
19310 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
19311 LockedRouteLockStartTime = LRVIT->LockStartTime;
19312 LockedRouteFoundDuringRouteBuilding =
true;
19313 LockedRouteVector.erase(LRVIT);
19338 AnsiString(VLoc) +
"," + AnsiString(ELink));
19341 ReturnPair.first = -1;
19342 ReturnPair.second = 0;
19343 THVPair Route2MultiMapKeyPair;
19345 Route2MultiMapKeyPair.first = HLoc;
19346 Route2MultiMapKeyPair.second = VLoc;
19349 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
19350 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19352 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19353 Route2MultiMapIterator = ItPair.first;
19355 if(ItPair.first == ItPair.second)
19357 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
19359 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
19361 ReturnPair.first = ItPair.first->second.first;
19362 ReturnPair.second = ItPair.first->second.second;
19363 Route2MultiMapIterator = ItPair.first;
19365 return(ReturnPair);
19368 if(ItPair.first == ItPair.second)
19370 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
19372 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
19374 ReturnPair.first = ItPair.first->second.first;
19375 ReturnPair.second = ItPair.first->second.second;
19376 Route2MultiMapIterator = ItPair.first;
19378 return(ReturnPair);
19381 return(ReturnPair);
19396 AnsiString(VLoc) +
"," + AnsiString(ELink));
19397 THVPair Route2MultiMapKeyPair;
19399 Route2MultiMapKeyPair.first = HLoc;
19400 Route2MultiMapKeyPair.second = VLoc;
19401 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
19403 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19405 if(ItPair.first == ItPair.second)
19411 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
19413 RouteNumber = ItPair.first->second.first;
19419 if(ItPair.first == ItPair.second)
19425 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
19427 RouteNumber = ItPair.first->second.first;
19448 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
19449 THVPair Route2MultiMapKeyPair;
19451 Route2MultiMapKeyPair.first = HLoc;
19452 Route2MultiMapKeyPair.second = VLoc;
19455 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
19458 RouteElementPair.first = RouteNumber;
19459 RouteElementPair.second = RouteElementNumber;
19460 Route2MultiMapEntry.second = RouteElementPair;
19462 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
19465 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
19466 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
19469 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
19470 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
19472 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
19474 Route2MultiMap.insert(Route2MultiMapEntry);
19479 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
19484 Route2MultiMap.insert(Route2MultiMapEntry);
19502 TempPair.first = -1;
19503 TempPair.second = 0;
19504 SecondPair = TempPair;
19506 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
19507 THVPair Route2MultiMapKeyPair;
19509 Route2MultiMapKeyPair.first = HLoc;
19510 Route2MultiMapKeyPair.second = VLoc;
19511 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
19516 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
19518 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
19520 return(Route2MultiMapIterator->second);
19522 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
19524 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
19525 TempPair = ItRange.first->second;
19526 SecondPair = (--ItRange.second)->second;
19549 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
19550 if(RouteElementPair.first == -1)
19553 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
19554 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
19556 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
19559 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
19560 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
19561 (AnsiString)Caller);
19563 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
19566 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
19567 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
19568 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
19569 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
19573 unsigned int SizeVal = 0;
19576 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
19578 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
19580 if(SizeVal != Route2MultiMap.size())
19582 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
19583 (AnsiString)Caller);
19599 if(!Route2MultiMap.empty())
19601 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
19603 if(Route2MultiMapIterator->second.first > RouteNumber)
19605 Route2MultiMapIterator->second.first--;
19622 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
19623 if(!Route2MultiMap.empty())
19625 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
19627 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
19629 Route2MultiMapIterator->second.second--;
19648 AnsiString(ELink));
19652 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
19653 if(RequiredRoutePair.first == -1)
19655 throw Exception(
"Failed to find route element in RemoveRouteElement");
19657 Route2MultiMap.erase(Route2MultiMapIterator);
19658 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
19661 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
19682 GetModifiableRouteAt(8, RequiredRoutePair.first).PrefDirVector.erase(GetModifiableRouteAt(33, RequiredRoutePair.first).PrefDirVector.begin() + RequiredRoutePair.second);
19693 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
19701 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
19703 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
19704 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
19705 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
19717 if(!LockedRouteVector.empty())
19721 if(LRVIT->RouteNumber > RequiredRoutePair.first)
19723 LRVIT->RouteNumber--;
19733 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
19735 AutoSigVectorIT->RouteNumber--;
19740 CheckMapAndRoutes(7);
19754 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
19755 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
19756 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
19772 "," + AnsiString(XLinkPos));
19776 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
19777 if(RouteElementPair.first == -1)
19779 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
19781 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
19783 RequiredPair = RouteElementPair;
19784 if(RouteElement.
XLinkPos != XLinkPos)
19786 if(SecondPair.first != -1)
19788 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
19789 RequiredPair = SecondPair;
19790 if(RouteElement.
XLinkPos != XLinkPos)
19792 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
19797 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
19801 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
19821 AnsiString(AccessNumber));
19823 int Attribute = AccessNumber + 1;
19825 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
19829 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
19833 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
19836 x).XLinkPos] !=
End)
19838 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
19841 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
19884 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
19885 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
19886 int RearwardLinkedRouteNumber;
19912 int TrainID, TrainPosition, BehindTrainPosition;
19913 bool FoundTrain =
false, BehindTrain =
false;
19914 for(
int x = RouteStartPosition; x >= 0; x--)
19916 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
19941 if(FoundTrain && (TrainPosition > 1))
19943 for(
int x = TrainPosition; x >= 0; x--)
19948 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
19968 BehindTrain =
true;
19969 BehindTrainPosition = x;
19976 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
19993 AnsiString(LookBackwardsFromHere));
19994 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber;
19995 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
19998 bool ExamineRoute =
true;
20000 while(ExamineRoute)
20002 for(
int x = LookBackwardsFromHere; x >= 0; x--)
20047 if(SignalCount >= 3)
20062 LookBackwardsFromHere = CurrentRoute.
PrefDirSize() - 1;
20066 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
20067 ExamineRoute =
true;
20068 LookBackwardsFromHere = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
20103 ExamineRoute =
false;
20118 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
20121 PrefDirElement = InternalPrefDirElement;
20122 if(LockedRouteVector.empty())
20129 bool InLockedRoute =
false;
20133 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
20137 InLockedRoute =
true;
20146 int RouteNumber, VectorCount = 0;
20151 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
20152 if(RouteType == NoRoute)
20165 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
20167 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
20172 PrefDirElement = InternalPrefDirElement;
20173 LockedVectorNumber = VectorCount;
20178 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->RearTrackVectorPosition)
20182 PrefDirElement = InternalPrefDirElement;
20183 LockedVectorNumber = VectorCount;
20204 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20206 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
20212 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
20222 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20224 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
20239 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20241 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
20244 return(GetFixedRouteAt(159, x));
20247 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
20255 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20257 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
20260 return(GetModifiableRouteAt(15, x));
20263 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
20273 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
20275 TOneRoute OneRoute = GetFixedRouteAt(165, x);
20287 int NumberOfRoutes;
20291 for(
int x = 0; x < NumberOfRoutes; x++)
20298 StoreOneRouteAfterSessionLoad(0, &OneRoute);
20316 if((NumberOfRoutes < 0) || (NumberOfRoutes > 5000))
20323 if((NextID < 0) || (NextID > 1000000))
20328 for(
int x = 0; x < NumberOfRoutes; x++)
20353 AnsiString(StartPosition));
20354 if(EndPosition == StartPosition)
20360 int TVPos = EndPosition;
20361 int LkPos = EndXLinkPos;
20363 while(TrackIsInARoute(15, TVPos, LkPos))
20390 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
20399 if((NewLkPos == 0) || (NewLkPos == 2))
20419 if(TVPos == StartPosition)
20451 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
20456 if(FirstPair.first > -1)
20459 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20464 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20470 if(SecondPair.first > -1)
20473 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20478 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20484 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(0, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(1, HLoc - 1, VLoc,
20491 if(FirstPair.first > -1)
20494 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20499 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20505 if(SecondPair.first > -1)
20508 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20513 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20519 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(2, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(3, HLoc, VLoc - 1,
20526 if(FirstPair.first > -1)
20529 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20534 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20540 if(SecondPair.first > -1)
20543 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20548 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20554 if(((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(4, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(5, HLoc + 1, VLoc,
20561 if(FirstPair.first > -1)
20564 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20569 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20575 if(SecondPair.first > -1)
20578 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20583 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20589 if(((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(6, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(7, HLoc, VLoc + 1,
20613 "," + AnsiString(DiagonalLinkNumber));
20618 if(FirstPair.first > -1)
20621 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20626 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20632 if(SecondPair.first > -1)
20635 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20640 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20647 if(FirstPair.first > -1)
20650 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20655 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20661 if(SecondPair.first > -1)
20664 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20669 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
20676 if(FirstPair.first > -1)
20679 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20684 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20690 if(SecondPair.first > -1)
20693 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20698 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
20705 if(FirstPair.first > -1)
20708 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20713 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
20719 if(SecondPair.first > -1)
20722 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
20727 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))